/** 
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
* 
* MeetTypeManageService
* 会议类型
* 
* 修改纪录
* 2020-10-23 版本：1.0 wanghongwei 创建。
* @version 版本：1.0
* @author 作者：wanghongwei
* 创建日期：2020-10-23
*/
package com.topscomm.meet.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.meet.pojo.MeetTypeManageEntity;
import com.topscomm.meet.service.IMeetTypeManageService;
import com.topscomm.meet.service.impl.auto.MeetTypeManageServiceAuto;
import com.topscomm.pub.util.ConvertUtil;

@Service(value = "meetTypeManageService")
@Scope(value = "singleton")
public class MeetTypeManageService extends MeetTypeManageServiceAuto implements IMeetTypeManageService {

	/**
	 * @description: 得到会议类型列表
	 * @param meetTypeList
	 * @return
	 * @author: wanghongwei
	 * @date: 2020-11-25 10:54:22
	 * @modify:
	 */
	@Override
	public List<Map<String, Object>> getSpliceList(List<Map<String, Object>> meetTypeList) {
		List<Map<String, Object>> spliceList = new ArrayList<>();
		for (Map<String, Object> meetTypeMap : meetTypeList) {
			String id = ConvertUtil.convertToString(meetTypeMap.get(MeetTypeManageEntity.FieldId));
			String name = ConvertUtil.convertToString(meetTypeMap.get(MeetTypeManageEntity.FieldName));
			String pId = ConvertUtil.convertToString(meetTypeMap.get(MeetTypeManageEntity.FieldParentid));
			if (pId.length() <= 1) {
				List<Map<String, Object>> childList = this.getChildList(meetTypeList, id);
				for (Map<String, Object> childMap : childList) {
					String childName = ConvertUtil.convertToString(childMap.get(MeetTypeManageEntity.FieldName));
					childMap.put("fullname", name + "/" + childName);
					spliceList.add(childMap);
				}
			}
		}
		return spliceList;
	}

	/**
	 * @description: 得到孩子列表
	 * @param meetTypeList
	 * @param parentId
	 * @author: wanghongwei
	 * @date: 2020-11-24 9:17:03
	 * @modify:
	 */
	private List<Map<String, Object>> getChildList(List<Map<String, Object>> meetTypeList, String parentId) {
		List<Map<String, Object>> childList = new ArrayList<>();
		for (Map<String, Object> meetTypeMap : meetTypeList) {
			String pId = ConvertUtil.convertToString(meetTypeMap.get(MeetTypeManageEntity.FieldParentid));
			if (Objects.equals(parentId, pId)) {
				childList.add(meetTypeMap);
			}
		}
		return childList;
	}

}
